<template>
    <div>
        my page
     <button @click="tourl"> params路由传参</button>
     <button @click="tourl2"> query路由传参</button>
    </div>
</template>

<script>

export default({
    data(){
        return {

        }
    },
    methods:{
        hh(){
            alert(1)
        },
        tourl(){
            /*
          命名的路由:router.push({ name: 'user', params: { userId: 123 }})
 
            带查询参数，变成/backend/order?selected=2: this.$router.push({path: '/backend/order', query: {selected: "2"}});
            */ 
            this.$router.push({name:"About",params:{name:"张三",old:16}})
           

        },
        tourl2(){
             this.$router.push({path: '/about', query: {name:"张5",old:15}});
        }
    },
    
    //生命周期函数  当页面内容全部加载完成之后执行代码
     mounted(){
       console.log(2)
    },
    // 生命周期函数 created 钩子可以用来在一个实例被创建之后执行代码
    created(){
       this.hh()
    },
})
</script>
